home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util4 / bytmrk20.lha / nbench0.h < prev    next >
C/C++ Source or Header  |  1995-11-04  |  9KB  |  303 lines

  1.  
  2. /*
  3. ** DEFINES and GLOBALS for NBENCH0.C
  4. */
  5.  
  6. /*
  7. ** Following should be modified accordingly per each
  8. ** compilation.
  9. */
  10. char *sysname="Amiga 68020 IEEE Math";
  11. char *compilername="SAS C/C++";
  12. char *compilerversion="ver 6.50";
  13.  
  14. /*  Parameter flags.  Must coincide with parameter names array
  15. ** which appears below. */
  16. #define PF_GMTICKS 0            /* GLOBALMINTICKS */
  17. #define PF_MINSECONDS 1         /* MINSECONDS */
  18. #define PF_ALLSTATS 2           /* ALLSTATS */
  19. #define PF_OUTFILE 3            /* OUTFILE */
  20. #define PF_CUSTOMRUN 4          /* CUSTOMRUN */
  21. #define PF_DONUM 5              /* DONUMSORT */
  22. #define PF_NUMNUMA 6            /* NUMNUMARRAYS */
  23. #define PF_NUMASIZE 7           /* NUMARRAYSIZE */
  24. #define PF_NUMMINS 8            /* NUMMINSECONDS */
  25. #define PF_DOSTR 9              /* DOSTRINGSORT */
  26. #define PF_STRASIZE 10          /* STRARRAYSIZE */
  27. #define PF_NUMSTRA 11           /* NUMSTRARRAYS */
  28. #define PF_STRMINS 12           /* STRMINSECONDS */
  29. #define PF_DOBITF 13            /* DOBITFIELD */
  30. #define PF_NUMBITOPS 14         /* NUMBITOPS */
  31. #define PF_BITFSIZE 15          /* BITFIELDSIZE */
  32. #define PF_BITMINS 16           /* BITMINSECONDS */
  33. #define PF_DOEMF 17             /* DOEMF */
  34. #define PF_EMFASIZE 18          /* EMFARRAYSIZE */
  35. #define PF_EMFLOOPS 19          /* EMFLOOPS */
  36. #define PF_EMFMINS 20           /* EMFMINSECOND */
  37. #define PF_DOFOUR 21            /* DOFOUR */
  38. #define PF_FOURASIZE 22         /* FOURASIZE */
  39. #define PF_FOURMINS 23          /* FOURMINSECONDS */
  40. #define PF_DOASSIGN 24          /* DOASSIGN */
  41. #define PF_AARRAYS 25           /* ASSIGNARRAYS */
  42. #define PF_ASSIGNMINS 26        /* ASSIGNMINSECONDS */
  43. #define PF_DOIDEA 27            /* DOIDEA */
  44. #define PF_IDEAASIZE 28         /* IDEAARRAYSIZE */
  45. #define PF_IDEALOOPS 29         /* IDEALOOPS */
  46. #define PF_IDEAMINS 30          /* IDEAMINSECONDS */
  47. #define PF_DOHUFF 31            /* DOHUFF */
  48. #define PF_HUFFASIZE 32         /* HUFFARRAYSIZE */
  49. #define PF_HUFFLOOPS 33         /* HUFFLOOPS */
  50. #define PF_HUFFMINS 34          /* HUFFMINSECONDS */
  51. #define PF_DONNET 35            /* DONNET */
  52. #define PF_NNETLOOPS 36         /* NNETLOOPS */
  53. #define PF_NNETMINS 37          /* NNETMINSECONDS */
  54. #define PF_DOLU 38              /* DOLU */
  55. #define PF_LUNARRAYS 39         /* LUNUMARRAYS */
  56. #define PF_LUMINS 40            /* LUMINSECONDS */
  57.  
  58. #define MAXPARAM 40
  59.  
  60. /* Tests-to-do flags...must coincide with test. */
  61. #define TF_NUMSORT 0
  62. #define TF_SSORT 1
  63. #define TF_BITOP 2
  64. #define TF_FPEMU 3
  65. #define TF_FFPU 4
  66. #define TF_ASSIGN 5
  67. #define TF_IDEA 6
  68. #define TF_HUFF 7
  69. #define TF_NNET 8
  70. #define TF_LU 9
  71.  
  72. #define NUMTESTS 10
  73.  
  74. /*
  75. ** GLOBALS
  76. */
  77.  
  78. /*
  79. ** Test names
  80. */
  81. char *ftestnames[] = {
  82.         "NUMERIC SORT",
  83.         "STRING SORT",
  84.         "BITFIELD",
  85.         "FP EMULATION",
  86.         "FOURIER",
  87.         "ASSIGNMENT",
  88.         "IDEA",
  89.         "HUFFMAN",
  90.         "NEURAL NET",
  91.         "LU DECOMPOSITION" };
  92.  
  93. /*
  94. ** Indexes -- Baseline is DELL Pentium XP90
  95. ** 11/28/94
  96. */
  97. double bindex[] = {
  98.     38.695,                     /* Numeric sort */
  99.     2.275,                      /* String sort */
  100.     5829828,                    /* Bitfield */
  101.     2.08,                       /* FP Emulation */
  102.     883.16,                     /* Fourier */
  103.     .26247,                     /* Assignment */
  104.     65.36,                      /* IDEA */
  105.     35.985,                     /* Huffman */
  106.     .591,                       /* Neural Net */
  107.     16.938 };                   /* LU Decomposition */
  108. /* Parameter names */
  109. char *paramnames[]= {
  110.         "GLOBALMINTICKS",
  111.         "MINSECONDS",
  112.         "ALLSTATS",
  113.         "OUTFILE",
  114.         "CUSTOMRUN",
  115.         "DONUMSORT",
  116.         "NUMNUMARRAYS",
  117.         "NUMARRAYSIZE",
  118.         "NUMMINSECONDS",
  119.         "DOSTRINGSORT",
  120.         "STRARRAYSIZE",
  121.         "NUMSTRARRAYS",
  122.         "STRMINSECONDS",
  123.         "DOBITFIELD",
  124.         "NUMBITOPS",
  125.         "BITFIELDSIZE",
  126.         "BITMINSECONDS",
  127.         "DOEMF",
  128.         "EMFARRAYSIZE",
  129.         "EMFLOOPS",
  130.         "EMFMINSECONDS",
  131.         "DOFOUR",
  132.         "FOURSIZE",
  133.         "FOURMINSECONDS",
  134.         "DOASSIGN",
  135.         "ASSIGNARRAYS",
  136.         "ASSIGNMINSECONDS",
  137.         "DOIDEA",
  138.         "IDEARRAYSIZE",
  139.         "IDEALOOPS",
  140.         "IDEAMINSECONDS",
  141.         "DOHUFF",
  142.         "HUFARRAYSIZE",
  143.         "HUFFLOOPS",
  144.         "HUFFMINSECONDS",
  145.         "DONNET",
  146.         "NNETLOOPS",
  147.         "NNETMINSECONDS",
  148.         "DOLU",
  149.         "LUNUMARRAYS",
  150.         "LUMINSECONDS" };
  151.  
  152. /*
  153. ** Following array is a collection of flags indicating which
  154. ** tests to perform.
  155. */
  156. int tests_to_do[NUMTESTS];
  157.  
  158. /*
  159. ** Buffer for holding output text.
  160. */
  161. char buffer[100];
  162.  
  163. /*
  164. ** Global parameters.
  165. */
  166. ulong global_min_ticks;         /* Minimum ticks */
  167. ulong global_min_seconds;       /* Minimum seconds tests run */
  168. int global_allstats;            /* Statistics dump flag */
  169. char global_ofile_name[60];     /* Output file name */
  170. FILE *global_ofile;             /* Output file */
  171. int global_custrun;             /* Custom run flag */
  172. int write_to_file;              /* Write output to file */
  173.  
  174. /*
  175. ** Following are global structures, one built for
  176. ** each of the tests.
  177. */
  178. SortStruct global_numsortstruct;        /* For numeric sort */
  179. SortStruct global_strsortstruct;        /* For string sort */
  180. BitOpStruct global_bitopstruct;         /* For bitfield operations */
  181. EmFloatStruct global_emfloatstruct;     /* For emul. float. point */
  182. FourierStruct global_fourierstruct;     /* For fourier test */
  183. AssignStruct global_assignstruct;       /* For assignment algorithm */
  184. IDEAStruct global_ideastruct;           /* For IDEA encryption */
  185. HuffStruct global_huffstruct;           /* For Huffman compression */
  186. NNetStruct global_nnetstruct;           /* For Neural Net */
  187. LUStruct global_lustruct;               /* For LU decomposition */
  188.  
  189. /*
  190. ** The following array of function struct pointers lets
  191. ** us very rapidly map a function to its controlling
  192. ** data structure. NOTE: These must match the "TF_xxx"
  193. ** constants above.
  194. */
  195. void *global_fstruct[] =
  196. {       (void *)&global_numsortstruct,
  197.         (void *)&global_strsortstruct,
  198.         (void *)&global_bitopstruct,
  199.         (void *)&global_emfloatstruct,
  200.         (void *)&global_fourierstruct,
  201.         (void *)&global_assignstruct,
  202.         (void *)&global_ideastruct,
  203.         (void *)&global_huffstruct,
  204.         (void *)&global_nnetstruct,
  205.         (void *)&global_lustruct };
  206.         
  207. /*
  208. ** Following globals added to support command line emulation on
  209. ** the Macintosh....which doesn't have command lines.
  210. */
  211. #ifdef MAC
  212. int argc;                       /* Argument count */
  213. char *argv[20];         /* Argument vectors */
  214.  
  215. unsigned char Uargbuff[129];    /* Buffer holding arguments string */
  216. unsigned char Udummy[2];                /* Dummy buffer for first arg */
  217.  
  218. #endif
  219.  
  220. #ifdef MACTIMEMGR
  221. #include <Types.h>
  222. #include <Timer.h>
  223. /*
  224. ** Timer globals for Mac
  225. */
  226. struct TMTask myTMTask;
  227. long MacHSTdelay,MacHSTohead;
  228.  
  229. #endif
  230.  
  231. /*
  232. ** Following globals used by Win 31 timing routines.
  233. ** NOTE: This requires the includes of the w31timer.asm
  234. ** file in your project!!
  235. */
  236. #ifdef WIN31TIMER
  237. #include <windows.h>
  238. #include <toolhelp.h>
  239. extern TIMERINFO win31tinfo;
  240. extern HANDLE hThlp;
  241. extern FARPROC lpfn;
  242. #endif
  243.  
  244. /*
  245. ** PROTOTYPES
  246. */
  247. static int parse_arg(char *argptr);
  248. static void display_help(char *progname);
  249. static void read_comfile(FILE *cfile);
  250. static int getflag(char *cptr);
  251. static void strtoupper(char *s);
  252. static void set_request_secs(void);
  253. static int bench_with_confidence(int fid,
  254.         double *mean, double *stdev, ulong *numtries);
  255. static int seek_confidence(double scores[5],
  256.         double *newscore, double *c_half_interval,
  257.         double *smean,double *sdev);
  258. static void calc_confidence(double scores[],
  259.         double *c_half_interval,double *smean,
  260.         double *sdev);
  261. static double getscore(int fid);
  262. static void output_string(char *buffer);
  263. static void show_stats(int bid);
  264.  
  265. #ifdef MAC
  266. void UCommandLine(void);
  267. void UParse(void);
  268. unsigned char *UField(unsigned char *ptr);
  269. #endif
  270.  
  271. /*
  272. ** EXTERNAL PROTOTYPES
  273. */
  274. extern void DoNumSort(void);    /* From NBENCH1 */
  275. extern void DoStringSort(void);
  276. extern void DoBitops(void);
  277. extern void DoEmFloat(void);
  278. extern void DoFourier(void);
  279. extern void DoAssign(void);
  280. extern void DoIDEA(void);
  281. extern void DoHuffman(void);
  282. extern void DoNNET(void);
  283. extern void DoLU(void);
  284.  
  285. extern void ErrorExit(void);    /* From SYSSPEC */
  286.  
  287. /*
  288. ** Array of pointers to the benchmark functions.
  289. */
  290. void (*funcpointer[])(void) =
  291. {       DoNumSort,
  292.         DoStringSort,
  293.         DoBitops,
  294.         DoEmFloat,
  295.         DoFourier,
  296.         DoAssign,
  297.         DoIDEA,
  298.         DoHuffman,
  299.         DoNNET,          
  300.         DoLU };
  301.  
  302.  
  303.